//package com.mocha.nezha;
//
//import cn.hutool.core.util.RandomUtil;
//import cn.hutool.core.util.StrUtil;
//import com.alibaba.fastjson.JSON;
//import com.mocha.nezha.dmo.VehicleTrackDTO;
//import com.mocha.nezha.nezha.VehicleTrackHandler;
//import com.scshyzh.concurrent.MochaExecutorManager;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.concurrent.Executor;
//import java.util.concurrent.TimeUnit;
//
///**
// * @author songkui
// * @since 2024/3/27 17:58
// */
//@Component
//@AllArgsConstructor
//@Slf4j
//public class TestC {
//
//    private final VehicleTrackHandler vehicleTrackHandler;
//    private final static String park = "jiangan";
//
//    @Scheduled(initialDelay = 120000, fixedRate = 20000) // 每隔5秒执行一次
//    public void task() throws InterruptedException {
//        MochaExecutorManager.getInstance().getDefaultExecutor().execute(() ->{
//            try {
//                int r = RandomUtil.randomInt(2, 5);
//                log.info("------------task-----{}--------------------", r);
//                for (int i=0; i< r; i++){
//                    doTask(buildPath1(oid(), caNo()));
//                    TimeUnit.MILLISECONDS.sleep(RandomUtil.randomInt(80, 200));
//                    doTask(buildPath2(oid(), caNo()));
//                }
//
//                TimeUnit.SECONDS.sleep(RandomUtil.randomInt(5,8));
//                r = RandomUtil.randomInt(1, 5);
//                log.info("------------task22-----{}--------------------", r);
//                for (int i=0; i< r; i++){
//                    doTask(buildPath1(oid(), caNo()));
//                    TimeUnit.MILLISECONDS.sleep(RandomUtil.randomInt(80, 200));
//                    doTask(buildPath2(oid(), caNo()));
//                }
//
//                TimeUnit.SECONDS.sleep(RandomUtil.randomInt(5, 8));
//                r = RandomUtil.randomInt(2, 5);
//                log.info("---------*****--task22-----{}--------------------", r);
//                for (int i=0; i< r; i++){
//                    doStepTask(buildPath1(oid(), caNo()));
//                    TimeUnit.MILLISECONDS.sleep(RandomUtil.randomInt(80, 200));
//                    doStepTask(buildPath2(oid(), caNo()));
//                }
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }
//        });
//
//
//    }
////
////    @Scheduled(initialDelay = 360000, fixedRate = 8000) // 每隔5秒执行一次
////    public void task2() throws InterruptedException {
////        int r = RandomUtil.randomInt(10, 20);
////        log.info("---------*****--task22-----{}--------------------", r);
////        for (int i=0; i< r; i++){H
////            doStepTask(buildPath1(oid(), caNo()));
////            TimeUnit.MILLISECONDS.sleep(500L);
////            doStepTask(buildPath4(oid(), caNo()));
////            TimeUnit.MILLISECONDS.sleep(500L);
////            doStepTask(buildPath3(oid(), caNo()));
////            TimeUnit.MILLISECONDS.sleep(500L);
////            doStepTask(buildPath2(oid(), caNo()));
////        }
////        TimeUnit.SECONDS.sleep(2L);
////        log.info("---------*****--task22-----{}--------------------", r);
////         r = RandomUtil.randomInt(80, 100);
////        for (int i=0; i< r; i++){
////            doTask(buildPath1(oid(), caNo()));
////            TimeUnit.MILLISECONDS.sleep(500L);
////            doTask(buildPath4(oid(), caNo()));
////            TimeUnit.MILLISECONDS.sleep(500L);
////            doTask(buildPath3(oid(), caNo()));
////            TimeUnit.MILLISECONDS.sleep(500L);
////            doTask(buildPath2(oid(), caNo()));
////        }
////    }
//
//
//
//    private static String caNo(){
//        return "川A-"+ RandomUtil.randomString(6);
//    }
//    private static String oid(){
//        return "object"+ RandomUtil.randomString(6);
//    }
//
//
//
//    // 十字路 右拐
//    private List<VehicleTrackDTO> buildPath1 (String oid, String cno){
//        List<VehicleTrackDTO> list = new ArrayList<>();
//        list.add(new VehicleTrackDTO("51171", oid, cno, 0, "", "", "car", 1, "51148"));
//        list.add(new VehicleTrackDTO("51171", oid, cno, 0, "", "", "car", 1, "51148"));
//        list.add(new VehicleTrackDTO("51171", oid, cno, 0, "", "", "car", 1, "51148"));
//        list.add(new VehicleTrackDTO("51171", oid, cno, 0, "", "", "car", 1, "51148"));
//        list.add(new VehicleTrackDTO("51171", oid, cno, 0, "", "", "car", 1, "51148"));
//        list.add(new VehicleTrackDTO("51171", oid, cno, 0, "", "", "car", 1, "51148"));
//        list.add(new VehicleTrackDTO("51171", oid, cno, 0, "", "", "car", 1, "51148"));
//        return list;
//    }
//
//    // 十字路 左拐
//    private List<VehicleTrackDTO> buildPath2 (String oid, String cno){
//        List<VehicleTrackDTO> list = new ArrayList<>();
//        list.add(new VehicleTrackDTO("51015", oid, cno, 0, "", "", "car", 1, "51228"));
//        list.add(new VehicleTrackDTO("51015", oid, cno, 0, "", "", "car", 1, "51228"));
//        list.add(new VehicleTrackDTO("51015", oid, cno, 0, "", "", "car", 1, "51228"));
//        list.add(new VehicleTrackDTO("51015", oid, cno, 0, "", "", "car", 1, "51228"));
//        list.add(new VehicleTrackDTO("51015", oid, cno, 0, "", "", "car", 1, "51228"));
//        list.add(new VehicleTrackDTO("51015", oid, cno, 0, "", "", "car", 1, "51228"));
//        list.add(new VehicleTrackDTO("51015", oid, cno, 0, "", "", "car", 1, "51228"));
//        return list;
//    }
//
//
//
//
//    private void doTask(List<VehicleTrackDTO> data){
//        for (VehicleTrackDTO dto : data){
//            if (StrUtil.isEmpty(dto.getCno()) || StrUtil.isEmpty(dto.getOid()) ){
//                log.warn("handler>>  pole or objectId is null");
//            }else {
//                Executor executor = MochaExecutorManager.getInstance().getDisruptor(dto.getOid().hashCode());
//                executor = null == executor ? MochaExecutorManager.getInstance().getDefaultExecutor() : executor;
//                executor.execute(() ->vehicleTrackHandler.doTrack(park, dto));
//            }
//        }
//    }
//    private void doStepTask(List<VehicleTrackDTO> data) throws InterruptedException {
//        for (VehicleTrackDTO dto : data){
//            if (StrUtil.isEmpty(dto.getCno()) || StrUtil.isEmpty(dto.getOid()) ){
//                log.warn("handler>>  pole or objectId is null");
//            }else {
//                Executor executor = MochaExecutorManager.getInstance().getDisruptor(dto.getOid().hashCode());
//                executor = null == executor ? MochaExecutorManager.getInstance().getDefaultExecutor() : executor;
//                executor.execute(() ->vehicleTrackHandler.doTrack(park, dto));
//            }
//            TimeUnit.SECONDS.sleep(RandomUtil.randomInt(1, 3));
//        }
//    }
//
//    public static void main(String[] args) {
//        VehicleTrackDTO x =   new VehicleTrackDTO("51171", oid(), caNo(), 0, "", "", "car", 1, "51148");
//        System.out.println(JSON.toJSONString(x));
//    }
//
//
//}
